<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <router-link to="/home">home</router-link>
        <router-link to="/set">set</router-link>
        <router-view></router-view>
    </div>
    <script src="./vue.js"></script>
    <script src="./vue-router.js"></script>
    <script>
        console.log(VueRouter);
        //第一步：定义组件对象

        let home = {
            template:'<h1>home</h1>'
        };

        let set = {
            template:'<h1>set</h1>'
        };

        let notPage = {
            template:'<h1>404</h1>'
        }

        //第二步：创建路由实例

        //第三步：定义路由规则

        let router = new VueRouter({
            routes:[
                {
                    path:'/',
                    redirect:'/home'  //路由重定向
                },
                {
                    path:'/home',
                    component:home
                },
                {
                    path:'/set',
                    component:set
                },
                {
                    path:'*',
                    component:notPage
                }
            ]
        })

        //第四步：在vue的实例上配置路由
        new Vue({
            el:'#app',
            router
        })
    </script>
</body>
</html>